package net.knightwatch.kwtools.walkthrough.items;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

import net.knightwatch.kwtools.customers.Building;
import net.knightwatch.kwtools.customers.Customer;
import android.os.SystemClock;

public class Item {
	private long itemId;
	private String name;
	private long potentialId;
	private ItemType itemType;
	private double latitude; 
	private double longitude;
	private double altitude;
	private Building building;
	private Customer customer;
	private ArrayList<Question> questions;
	private long timeElapsedMillis;
	
	// Methods
	/**
	 * Item default constructor. The item requires that a itemType is built and sent back, along with a building and a customer
	 * @param itemType
	 * @param building
	 * @param customer
	 */
	public Item(){
		// Initialize all array lists to avoid null pointer exceptions. s
		this.questions = new ArrayList<Question>();
	}
	public long getItemId() {
		return itemId;
	}
	public void setItemId(long itemId) {
		this.itemId = itemId;
	}
	public Double getLatitude() {
		return latitude;
	}
	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}
	public Double getLongitude() {
		return longitude;
	}
	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}
	public Double getAltitude(){
		return altitude;
	}
	public void setAltitude(Double altitude){
		this.altitude = altitude;
	}
	public Building getBuilding() {
		return building;
	}
	public void setBuilding(Building building) {
		this.building = building;
	}
	public ArrayList<Question> getQuestions() {
		return questions;
	}
	public void setQuestions(ArrayList<Question> questions) {
		this.questions = questions;
	}
	public ItemType getItemType() {
		return itemType;
	}
	public void setItemType(ItemType itemType) {
		this.itemType = itemType;
	}
	public Customer getCustomer() {
		return customer;
	}
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	public long getPotentialId() {
		return potentialId;
	}
	public void setPotentialId(long potentialId) {
		this.potentialId = potentialId;
	}
	public long getTimeElapsedMillis() {
		return timeElapsedMillis;
	}
	public void setTimeElapsedMillis(long timeElapsedMillis) {
		this.timeElapsedMillis = timeElapsedMillis;
	}
	/**
	 * Returns a String value of the time it took start to finish with an item. Passed to this function is the time in ms it took.
	 * @param timerBase
	 * @return
	 */
	public String getTotalTime(long timerBase) {
		// Return the total time it took to create the item.
		this.setTimeElapsedMillis(timerBase);
		long totalElapsedMillis = SystemClock.elapsedRealtime() - this.getTimeElapsedMillis();
		SimpleDateFormat df = new SimpleDateFormat("mm:ss");
		String time = df.format(totalElapsedMillis);
		return time;
	}
	/**
	 * Sets the String name of the Item
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * Returns the String name of the Item
	 * @return
	 */
	public String getName(){
		return this.name;
	}
	
}
